//
//  WDPlaceholderView.m
//  Zhihuijinfu
//
//  Created by 王笛 on 2017/2/28.
//  Copyright © 2017年 王笛. All rights reserved.
//

#import "WDPlaceholderView.h"

@interface WDPlaceholderView ()
/** 占位图 */
@property(nonatomic, weak) UIImageView *placehView;
/** 文字说明 */
@property(nonatomic, weak) UILabel *statusLabel;

@end

@implementation WDPlaceholderView

+ (instancetype)placeholderViewWithImageName:(NSString *)imageName status:(NSString *)status
{
    WDPlaceholderView *view = [[WDPlaceholderView alloc] init];
    view.imageName = imageName;
    view.status = status;
    
    return view;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        UIImageView *imageView = [[UIImageView alloc] init];
        
        [self addSubview:imageView];
        
        self.placehView = imageView;
        
        [imageView makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.centerX);
//            make.width.equalTo(103);
//            make.height.equalTo(88);
            make.top.equalTo(0);
        }];
        
        UILabel *statusLabel = [[UILabel alloc] init];
        
        statusLabel.textColor = ColorForRGB(0x6b6b6b);
        
        statusLabel.font = [UIFont systemFontOfSize:15];
        
        statusLabel.textAlignment = NSTextAlignmentCenter;
        
        [self addSubview:statusLabel];
        
        self.statusLabel = statusLabel;
        
        [statusLabel makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.centerX);
            make.top.equalTo(imageView.bottom).offset(15);
        }];
        
    }
    
    return self;
}

- (void)setImageName:(NSString *)imageName
{
    _imageName = imageName;
    
    self.placehView.image = [UIImage imageNamed:imageName];
}

- (void)setStatus:(NSString *)status
{
    _status = status;
    
    self.statusLabel.text = status;
}

@end
